import { createApp } from 'vue'

// 全局 css
import '@/assets/styles/index.scss'
import 'element-plus/dist/index.css'

// App、router、store
import App from './App.vue'
import router from './router/index'
import { createPinia } from 'pinia'

// 自定义指令
import directive from './directive/index'

// 自定义插件对象
import plugins from './plugins/index'

// 本地svg图标
import 'virtual:svg-icons-register'
import SvgIcon from '@/components/SvgIcon'

// ElementPlus图标
import * as ElementPlusIconsVue from '@element-plus/icons-vue'

// 全局路由守卫
import './controller'

// mock接口数据
import '../mock/index'

import { parseTime, resetForm, addDateRange, handleTree, selectDictLabel, selectDictLabels } from '@/utils/ruoyi'

const app = createApp(App)
// 全局方法挂载
app.config.globalProperties.parseTime = parseTime
app.config.globalProperties.resetForm = resetForm
app.config.globalProperties.addDateRange = addDateRange
app.config.globalProperties.handleTree = handleTree
app.config.globalProperties.selectDictLabel = selectDictLabel
app.config.globalProperties.selectDictLabels = selectDictLabels

app.use(router)
app.use(createPinia())
app.use(plugins)
directive(app)
// 全局注册svg图标
app.component('svg-icon', SvgIcon)
// 全局注册elementplus图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}
app.mount('#app')
